﻿using System;
using System.Collections.Generic;
using System.Linq;
using AOPDemo.Domain;

namespace AOPDemo.Data
{
    public class Transactions : Dictionary<string, IList<Transaction>>
    {
        public Transactions()
        {
            var accounts = new Accounts();
            foreach (var accountMap in accounts)
            {
                foreach (Account account in accountMap.Value)
                {
                    Add(account.Id, new List<Transaction>());
                    for (int i = 0; i < 10; i++)
                    {
                        this[account.Id].Add(new Transaction
                                                 {
                                                     Amount = i*10,
                                                     Date = DateTime.Now.AddDays(-1*i),
                                                     FromAccountId = account.Id,
                                                     ToAccountId = accounts.First().Value.First().Id,
                                                     Id = string.Format("{0}_{1}", account.Id, i),
                                                     Type = "Transfer"
                                                 });
                    }
                }
            }
        }
    }

    public class Accounts : Dictionary<string, IList<Account>>
    {
        public Accounts()
        {
            var users = new Users();
            foreach (var user in users)
            {
                Add(user.Key, new List<Account>());
                for (int i = 0; i < 5; i++)
                    this[user.Key].Add(new Account
                                           {
                                               Balance = i*5,
                                               Id = user.Key + i,
                                               Name = "Account " + i,
                                               Type = "Checking"
                                           });
            }
        }
    }

    public class Users : Dictionary<string, User>
    {
        public Users()
        {
            Add("BigBank.JohnSmith", new User
                                         {
                                             UserName = "JohnSmith",
                                             Password = "P@assword!"
                                         });
            Add("BigBank.BigBrother199", new User
                                             {
                                                 UserName = "BigBrother199",
                                                 Password = "SomePassword**"
                                             });
            Add("CreditUnionA.SallySmith", new User
                                               {
                                                   UserName = "SallySmith",
                                                   Password = "383&^@@"
                                               });
        }
    }
}